/*******************************************************************
* Before including this file you have to define:
* 	#define MAX_PLAYERS //max players
* 	#define MAX_DEALERS //max dealers
*
*	enum _:ITEMS {
*		//your items
*	}
*
* If you are including this file you have to:
*	- register cvars with command register_def_cvars(const prefix[]);
*		registered cvars are:
*			[prefix]_auto_buy_cost_type (default 1) - Sets autobuy cost type
*				0 - nothing
*				1 - if user is buying automaticly he will pay additional money
*					realCost = cost + [prefix]_auto_buy_cost_val
*				2 - if user is buying automaticly he will pay additional % of real cost 
*					realCost = cost + (cost * [prefix]_auto_buy_cost_val)
*
*			[prefix]_auto_buy_cost_val (default 300) - Additional cost for faster buying items
*				if([prefix]_auto_buy_cost_type == 1) it is integer
*				if([prefix]_auto_buy_cost_type == 2) it is float
*
*********************************************************************/

#if defined _dealers_def_included
	#endinput
#endif

#define _dealers_def_included

#define NO_DEALER -1
#define MAX_DEALER_NAME_LEN 32

enum DealerRefreshAction {
	Dra_Never,
	Dra_OnLost,
	Dra_Always
}
enum _:DealerInfo {
	Di_Name[MAX_DEALER_NAME_LEN],
	DealerRefreshAction:Di_RefreshItems,
	Di_RefreshItemsMinCount,
	Di_RefreshItemsDropOld,
	Di_Registered
}

enum _:ItemInfo {
	Ii_MinCount,
	Ii_MaxCount,
	Ii_MinChance,
	Ii_MaxChance,
	Ii_MinCost,
	Ii_MaxCost
}

enum _:DealerItemInfo{
	Dii_Count,
	Dii_Cost
}

new gCvarAutoBuyCostType;
new gCvarAutoBuyCostVal;


// This stores informations on dealer
new gDealerDef[MAX_DEALERS][DealerInfo];

// This stores information about what items dealer can have, price and count
new gDealersItemsDefs[MAX_DEALERS][ITEMS][ItemInfo];

// This stores informations about real items dealer has
new gDealersItems[MAX_DEALERS][ITEMS][DealerItemInfo];

// This stores information on whitch dealer player selects from menu
new playerDealer[MAX_PLAYERS];

// This stores information on whitch item player selects from menu
new playerItem[MAX_PLAYERS];

// This stores information on whitch dealer is available to player
new playerAvailableDealers[MAX_PLAYERS][MAX_DEALERS];

// This stores information on whitch item is available to player
new playerAvailableItems[MAX_PLAYERS][ITEMS];

stock register_def_cvars(const prefix[]){
	new cvar[64];
	formatex(cvar, charsmax(cvar), "%s_auto_buy_cost_type", prefix)
	gCvarAutoBuyCostType = register_cvar(cvar, "1");
	
	cvar[0] = '^0';
	formatex(cvar, charsmax(cvar), "%s_auto_buy_cost_val", prefix)
	gCvarAutoBuyCostVal = register_cvar(cvar, "300");
}

stock d_client_connect(id){
	d_set_player_dealers(id, true);
	d_set_player_items(id, true);
}
